home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / size / RCS / printSpur.c,v < prev    next >
Encoding:
Text File  |  1989-05-17  |  3.3 KB  |  134 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     89.05.16.23.52.25;  author jhh;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* 
  26.  * spurPrint.c --
  27.  *
  28.  *    Contains the machine specific routine for printing the size if the
  29.  *    machine is a spur.
  30.  *
  31.  * Copyright 1989 Regents of the University of California
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that the above copyright
  35.  * notice appear in all copies.  The University of California
  36.  * makes no representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  */
  40.  
  41. #ifndef lint
  42. static char rcsid[] = "$Header: /sprite/users/jhh/src/size/RCS/spurPrint.c,v 1.1 89/03/30 16:35:13 jhh Exp Locker: jhh $ SPRITE (Berkeley)";
  43. #endif /* not lint */
  44.  
  45. #include <spur.md/sys/exec.h>
  46. #include <spur.md/a.out.h>
  47. #include "size.h"
  48.  
  49.  
  50. /*
  51.  *----------------------------------------------------------------------
  52.  *
  53.  * PrintSpur --
  54.  *
  55.  *    Prints out the size information for a spur a.out file.
  56.  *
  57.  * Results:
  58.  *    SUCCESS if size information was printed, FAILURE otherwise.
  59.  *
  60.  * Side effects:
  61.  *    Stuff is printed.
  62.  *
  63.  *----------------------------------------------------------------------
  64.  */
  65.  
  66. ReturnStatus
  67. PrintSpur(fp, printName, fileName, printHeadings, bufferSize, buffer)
  68.     FILE    *fp;        /* file that header was read from */
  69.     Boolean    printName;    /* TRUE => print name of file */
  70.     char    *fileName;    /* name of file */
  71.     Boolean    printHeadings;    /* TRUE => print column headings */
  72.     int        bufferSize;    /* size of buffer */
  73.     char    *buffer;    /* buffer containing header */
  74. {
  75.  
  76.     struct exec        *header;
  77.     char        swappedHeader[sizeof(*header) * 2];
  78.     int            swappedSize = sizeof(swappedHeader);
  79.     int            status;
  80.  
  81.     if (bufferSize < sizeof(struct exec)) {
  82.     return FAILURE;
  83.     }
  84.     header = (struct exec *) buffer;
  85.     if (!N_BADMAG(*header)) {
  86.     goto doPrint;
  87.     }
  88.     if (FMT_SPUR_FORMAT != hostFmt) {
  89.     status = Fmt_Convert("{w12}", FMT_SPUR_FORMAT, &bufferSize, buffer,
  90.             hostFmt, &swappedSize, swappedHeader);
  91.     if (status) {
  92.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  93.         return FAILURE;
  94.     }
  95.     header = (struct exec *) swappedHeader;
  96.     if (!N_BADMAG(*header)) {
  97.         goto doPrint;
  98.     }
  99.     }
  100.     if (FMT_68K_FORMAT != hostFmt) {
  101.     status = Fmt_Convert("{w12}", FMT_68K_FORMAT, &bufferSize, buffer,
  102.             hostFmt, &swappedSize, swappedHeader);
  103.     if (status) {
  104.         fprintf(stderr, "Fmt_Convert returned %d.\n", status);
  105.         return FAILURE;
  106.     }
  107.     header = (struct exec *) swappedHeader;
  108.     printf("spur magic 0x%x\n", header->a_magic);
  109.     if (!N_BADMAG(*header)) {
  110.         goto doPrint;
  111.     }
  112.     }
  113.     return FAILURE;
  114. doPrint:
  115.     if (printHeadings) {
  116.     printf("%-7s %-7s %-7s %-7s %-7s %-7s %-7s\n", 
  117.         "text", "data", "bss", "sdata", "sbss", "dec", "hex");
  118.     }
  119.     printf("%-7d %-7d %-7d %-7d %-7d %-7d %-7x",
  120.            header->a_text, header->a_data, header->a_bss,
  121.            header->a_sdata, header->a_sbss,
  122.            header->a_text + header->a_data + header->a_bss +
  123.            header->a_sbss + header->a_sdata,
  124.            header->a_text + header->a_data + header->a_bss +
  125.            header->a_sbss + header->a_sdata);
  126.     if (printName) {
  127.     printf("\t%s\n", fileName);
  128.     } else {
  129.     printf("\n");
  130.     }
  131.     return SUCCESS;
  132. }
  133. @
  134.